package id

import (
	"os"
	"strconv"
	"strings"
	"time"
)

// 76561198365925917
// 167410940000
// 16743010940000
// 10446749535109

func CreateCode(num int) string {
	str := strconv.FormatInt(time.Now().UnixNano(), 10)
	str = strconv.Itoa(os.Getpid()) + str
	return str[len(str)-num:]
}

func CreateUserID() int64 {
	str := strconv.FormatInt(time.Now().UnixNano(), 10)
	s := strings.Join([]string{
		str[2:],
		strconv.Itoa(os.Getpid()),
		strconv.Itoa(os.Geteuid()),
	}, "")[2:11]
	parseInt, _ := strconv.ParseInt(s, 10, 32)

	return parseInt

}
func CreateOrderID(user string) string {
	timeString := time.Now().Format(time.DateTime)
	str := strings.ReplaceAll(strings.ReplaceAll(timeString, "-", ""), ":", "")
	str = strings.ReplaceAll(str, " ", "")
	return str + user
}
